# Contributor: Damian Kurek <starfire24680@gmail.com>
# Maintainer: Damian Kurek <starfire24680@gmail.com>
pkgname=kodi-game-libretro-mgba
pkgver=0.11.0.44
_realname=Nexus
pkgrel=0
pkgdesc="mGBA for Kodi"
options="!check" # no test suite
url="https://github.com/kodi-game/game.libretro.mgba"
arch="x86_64 aarch64 armv7" # kodi is available only on these architectures
license="MPL-2.0"
makedepends="cmake kodi-dev samurai"
depends="kodi-game-libretro libretro-mgba"
source="$pkgname-$pkgver-$_realname.tar.gz::https://github.com/kodi-game/game.libretro.mgba/archive/$pkgver-$_realname.tar.gz"
builddir="$srcdir/game.libretro.mgba-$pkgver-$_realname"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_MODULE_PATH=/usr/lib/cmake/kodi
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	rm -r "$pkgdir"/usr/share/kodi/addons/game.libretro.mgba/resources/icon.png \
		"$pkgdir"/usr/share/kodi/addons/game.libretro.mgba/resources/screenshot* \
		"$pkgdir"/usr/lib/kodi/addons/game.libretro.mgba/game.libretro.mgba.so
	ln -s /usr/lib/libretro/mgba_libretro.so \
		"$pkgdir"/usr/lib/kodi/addons/game.libretro.mgba/game.libretro.mgba.so
	sed -i '/<assets>/,/<\/assets>/d' "$pkgdir"/usr/share/kodi/addons/game.libretro.mgba/addon.xml
}

sha512sums="
5ba66fae0349ffc8d0eb3760d1ac8e38cb83f7e75dfb50d942ac304fa60059e63449965a8a2480f1989f40e6527774ba8350f5cbc788d6fef33de1b872469f94  kodi-game-libretro-mgba-0.11.0.44-Nexus.tar.gz
"
